class PrecondicoesController < ApplicationController
  # GET /precondicoes
  # GET /precondicoes.xml
  def index
    @precondicoes = Precondicao.find(:all)
    @incentivos = Incentivo.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @precondicoes }
    end
  end

  # GET /precondicoes/1
  # GET /precondicoes/1.xml
  def show
    @precondicao = Precondicao.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @precondicao }
    end
  end

  # GET /precondicoes/new
  # GET /precondicoes/new.xml
  def new
    @precondicao = Precondicao.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @precondicao }
    end
  end

  # GET /precondicoes/1/edit
  def edit
    @precondicao = Precondicao.find(params[:id])
  end

  # POST /precondicoes
  # POST /precondicoes.xml
  def create
    @precondicao = Precondicao.new(params[:precondicao])

    respond_to do |format|
      if @precondicao.save
        flash[:notice] = 'Precondicao cadastrado(a) com sucesso.'
        format.html { redirect_to(@precondicao) }
        format.xml  { render :xml => @precondicao, :status => :created, :location => @precondicao }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @precondicao.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /precondicoes/1
  # PUT /precondicoes/1.xml
  def update
    @precondicao = Precondicao.find(params[:id])

    respond_to do |format|
      if @precondicao.update_attributes(params[:precondicao])
        flash[:notice] = 'Precondicao atualizado(a) com sucesso.'
        format.html { redirect_to(@precondicao) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @precondicao.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /precondicoes/1
  # DELETE /precondicoes/1.xml
  def destroy
    @precondicao = Precondicao.find(params[:id])
    @precondicao.destroy

    respond_to do |format|
      format.html { redirect_to(precondicoes_url) }
      format.xml  { head :ok }
    end
  end
  
end
